﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 逻辑
{
    public class 兵:QiZi
    {
        public 兵( int x, int y, QiPan q,  Button[,] b,int p) : base("兵", x, y, q, p, b)
        {
        }
        public override void CanPut()
        {
            canPut.Clear();
            if (x <= 4)
            {
                if (buttons[x + 1, y].Tag == null || (buttons[x + 1, y].Tag as QiZi).Player != this.Player)
                {
                    int z = Game.ChangeDirection(this.Player, x + 1);
                    canPut.Add(z * 10 + y);
                }
            }
            else if(x>4)
            {
                if(x+1<=9&&(buttons[x + 1, y].Tag == null || (buttons[x + 1, y].Tag as QiZi).Player != this.Player))
                {
                    int z = Game.ChangeDirection(this.Player, x + 1);
                    canPut.Add(z * 10 + y);
                }
                if(y+1<=8 && (buttons[x , y+1].Tag == null || (buttons[x , y+1].Tag as QiZi).Player != this.Player))
                {
                    int z = Game.ChangeDirection(this.Player, x);
                    canPut.Add(z * 10 + y+1);
                }
                if (y - 1 >= 0 && (buttons[x, y - 1].Tag == null || (buttons[x, y - 1].Tag as QiZi).Player != this.Player))
                {
                    int z = Game.ChangeDirection(this.Player, x);
                    canPut.Add(z * 10 + y - 1);
                }
            }
        }
    }
}
